package xyz.tanxiao.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 查询条件Demo
 *
 * @author 万成波
 * @email 2300064869@qq.com
 * @createTime 2024-09-11 17:14:30 星期三
 */
@Data
public class ConditionDemo {

	@Condition(type = ConditionType.EQ)
	private String a1;

	@Condition(type = ConditionType.EQ)
	private Integer a2;

	@Condition(type = ConditionType.LIKE)
	private String a3;

	@Condition(type = ConditionType.EQ, format = "yyyy-MM-dd")
	private Date a4;

	@Condition(type = ConditionType.EQ, format = "yyyy-MM-dd")
	private LocalDate a5;

	@Condition(type = ConditionType.EQ, format = "yyyy-MM-dd")
	private LocalDateTime a6;

	@Condition(type = ConditionType.IN)
	private List<Integer> a7;

	@Condition(type = ConditionType.NOT_IN)
	private List<String> a8;

	@Condition(type = ConditionType.IS_NULL)
	private String a9;

	@Condition(type = ConditionType.IS_NULL)
	private Integer a10;

	@Condition(type = ConditionType.IS_NOT_NULL)
	private String a11;

	@Condition(type = ConditionType.IS_NOT_NULL)
	private Date a12;


	@Condition(type = ConditionType.BETWEEN, betweenGroup = "b1")
	private String a13;

	@Condition(type = ConditionType.BETWEEN, betweenGroup = "b1", betweenSlave = true)
	private String a14;


	@Condition(type = ConditionType.BETWEEN, format = "yyyy-MM-dd", betweenGroup = "b2")
	private Date a15;

	@Condition(type = ConditionType.BETWEEN, format = "yyyy-MM-dd", betweenGroup = "b2", betweenSlave = true)
	private Date a16;


	@Condition(type = ConditionType.BETWEEN, format = "yyyy-MM-dd", betweenGroup = "b3")
	private LocalDateTime a17;

	@Condition(type = ConditionType.BETWEEN, format = "yyyy-MM-dd", betweenGroup = "b3", betweenSlave = true)
	private LocalDateTime a18;


	@Condition(type = ConditionType.BETWEEN, betweenGroup = "b4")
	private Integer a19;

	@Condition(type = ConditionType.BETWEEN, betweenGroup = "b4", betweenSlave = true)
	private Integer a20;


	@Condition(type = ConditionType.ASC_SORT, sortOrder = 1)
	private String a21;

	@Condition(type = ConditionType.DESC_SORT, sortOrder = 2)
	private Integer a22;


	public static void main(String[] args) {

		ConditionDemo demo = new ConditionDemo();
		demo.setA1("setA1");
		demo.setA2(0);
		demo.setA3("setA2");
		demo.setA4(new Date());
		demo.setA5(LocalDate.now());
		demo.setA6(LocalDateTime.now());
		demo.setA7(Arrays.asList(1, 2, 3));
		demo.setA8(Arrays.asList("1", "2", "3"));
		demo.setA13("2024-09-09");
		demo.setA14("2024-09-09");
		demo.setA15(new Date());
		demo.setA16(new Date());
		demo.setA17(LocalDateTime.now());
		demo.setA18(LocalDateTime.now());
		demo.setA19(10);
		demo.setA20(100);

		// 通过查询条件构建 QueryWrapper
		QueryWrapper<ConditionDemo> wrapper = QueryWrapperBuilder.build(demo);

	}

}